import '../helper/dioHelper.dart';

class XHSSZT {
  int Id;
  int TypeId;
  String Name;
  int State;
  String BeginTM;
  String EndTM;
  String CreateTM;
  String OKTM;
  String Remark;

  XHSSZT(this.Id, this.TypeId, this.Name, this.State, this.BeginTM, this.EndTM,
      this.CreateTM, this.OKTM, this.Remark);
  XHSSZT.fromJson(Map<String, dynamic> json)
      : Id = json["Id"],
        TypeId = json["TypeId"],
        Name = json["Name"],
        State = json["State"],
        BeginTM = json["BeginTM"],
        EndTM = json["EndTM"],
        CreateTM = json["CreateTM"],
        OKTM = json["OKTM"],
        Remark = json["Remark"];
  Map<String, dynamic> toJson() => {
        'Id': Id,
        'TypeId': TypeId,
        'Name': Name,
        'State': State,
        'BeginTM': BeginTM,
        'EndTM': EndTM,
        'CreateTM': CreateTM,
        'OKTM': OKTM,
        'Remark': Remark,
      };
  static Future<bool> Add(XHSSZT x1) async {
    var response = await DioHelper.Post("/XHSSZT/Add", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Update(XHSSZT x1) async {
    var response = await DioHelper.Post("/XHSSZT/Update", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Delete(XHSSZT x1) async {
    var st = x1.toJson();
    var response = await DioHelper.Post("/XHSSZT/Delete", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<XHSSZT?> Get(String where, dynamic data) async {
    var response = await DioHelper.Post("/XHSSZT/GetByWhere", {
      "Where": where,
      "obj": data,
    });

    if (response.statusCode == 200) return new XHSSZT.fromJson(response.data);
    return null;
  }

  static Future<List<XHSSZT>> GetList(
      String where, dynamic data, int pageIndex, int pageSize) async {
    var response = await DioHelper.Post("/XHSSZT/GetListByWhere", {
      "Where": where,
      "obj": data,
      "PageIndex": pageIndex,
      "PageSize": pageSize,
    });
    var list1 = <XHSSZT>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new XHSSZT.fromJson(x));
      }
    }
    return list1;
  }

  static Future<List<XHSSZT>> GetAllList() async {
    var response = await DioHelper.Get("/XHSSZT/GetAllList", {});
    var list1 = <XHSSZT>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new XHSSZT.fromJson(x));
      }
    }
    return list1;
  }
}
